package com.zhouyu.service;

import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValues;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class MyInstantiationAwareBeanPostProcessor implements InstantiationAwareBeanPostProcessor {

//	@Autowired
//	private MyAutowireAnnotationBeanPostProcessor myAutowireAnnotationBeanPostProcessor;

	@Override
	public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
		if ("user1".equals(beanName)) {
			System.out.println("InstantiationAwareBeanPostProcessor -----postProcessBeforeInstantiation + user1");
		}
		return null;
	}

	@Override
	public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException {
		if ("user1".equals(beanName)) {
			System.out.println("InstantiationAwareBeanPostProcessor---postProcessAfterInstantiation + user1");
		}
		return false;
	}

	@Override
	public PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName) throws BeansException {
		if ("user1".equals(beanName)) {
			System.out.println("InstantiationAwareBeanPostProcessor---postProcessProperties + user1");
		}
		return null;
	}

	@Bean
	public AAA aaa(){
		return new AAA();
	}

	static  class AAA{

	}


}
